package edu.uclm.esi.tysw.podtube.persistence;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.CallableStatement;
import java.sql.SQLException;

import edu.uclm.esi.tysw.podtube.domain.Audio;
public class AudioDAO {

	public static void insert(Audio audio) throws SQLException, FileNotFoundException {
		Conexion bd = Broker.get().getBD();
		try {
			File file=new File(audio.getTempFileName());
			FileInputStream fi=new FileInputStream(file);
			CallableStatement cs=bd.prepareCall("{call insertarAudio (?, ?)}");
			cs.setString(1, audio.getHash());
			cs.setBytes(2, audio.getContenido());
			cs.executeUpdate();
		}
		finally {
			bd.close();
		}
	}

}
